
//钱包的domain/BO
public class WalletDomain {
    private int id;
    private double money = 10000;//钱包的余额
    private boolean AllowedOverDraft = false;//是否允许贷款？初始为0
    private double FrozenMoney = 0;//冻结的钱款
    private double money1 = 0;//透支额度



    public WalletDomain(int id) {
        this.id = id;
    }

    public double getFrozenMoney() {
        return FrozenMoney;
    }

    public void setFrozenMoney(double n) {
        this.FrozenMoney = n;
    }

    public void setAllowedOverDraft(boolean e) {
        AllowedOverDraft = e;
    }

    public boolean getAllowed() {
        return AllowedOverDraft;
    }

    public int getId() {
        return id;
    }

    public double getMoney() {
        return money;
    }

    public double getRealMoney() {
        return money - FrozenMoney + money1;
    }

    public void deposit(double n) {
        if (n <= 0) {
            System.out.println("非法参数传入");
            return;
        }
        money += n;
    }

    public void CashOut(double n) {
        if (n <= 0) {
            System.out.println("非法参数传入");
            return;
        }
        if (n >= money - FrozenMoney) {
            System.out.println("余额不足！");
            return;
        }
        money -= n;
    }

    public void pay(double n){
        if (n <= 0) {
            System.out.println("非法参数传入");
            return;
        }
        if (n >= money - FrozenMoney) {
            System.out.println("余额不足！");
            return;
        }
        money -= n;
    }

    public void freeze(double n){
        if (n <= 0) {
            System.out.println("非法参数传入");
            return;
        }
        if (n >= money - FrozenMoney) {
            System.out.println("你没有那么多余额可以冻结");
            return;
        }
        FrozenMoney += n;
    }

    public void apply(boolean e){
        System.out.println("更改透支权限为:"+e+"\n");
        setAllowedOverDraft(e);
    }

    public void getApply(double n){
        if(this.getAllowed() == false){
            System.out.println("无透支权限\n");
            return;
        }
        money1 += n;
        System.out.println("目前透支额度为"+money1+"\n");
    }


}
